<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>请给我5s</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "楷体", "KaiTi", serif;
        }
        
        body {
            overflow: hidden;
            height: 100vh;
            background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
            transition: background 1.5s ease;
        }

        /* 开始按钮美化 */
        #startBtn {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            padding: 16px 32px;
            font-size: 22px;
            cursor: pointer;
            background: #FF69B4;
            color: white;
            border: none;
            border-radius: 50px;
            box-shadow: 0 5px 15px rgba(255,105,180,0.3);
            transition: all 0.3s ease;
            z-index: 1000;
        }

        #startBtn:hover {
            transform: translate(-50%, -50%) scale(1.05);
            box-shadow: 0 8px 20px rgba(255,105,180,0.4);
        }

        #startBtn:active {
            transform: translate(-50%, -50%) scale(0.98);
        }
        
        /* 弹幕窗口样式 */
        .tip-window {
            position: absolute;
            padding: 12px 15px;
            border-radius: 8px;
            box-shadow: 0 3px 10px rgba(0,0,0,0.08);
            font-size: 14px;
            font-weight: bold;
            opacity: 0;
            transform: scale(0.8);
            transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
            z-index: 100;
        }

        /* 弹幕出现动画类 */
        .tip-window.show {
            opacity: 1;
            transform: scale(1);
        }
        
        /* 最终弹窗样式 */
        .miss-window {
            position: fixed;
            background-color: #FFE4E1;
            border-radius: 15px;
            box-shadow: 0 8px 30px rgba(255,105,180,0.35);
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transform: scale(0.9);
            transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
            z-index: 200;
        }
        
        .miss-text {
            color: #CD5C5C;
            font-size: 28px;
            font-weight: bold;
            text-shadow: 0 2px 4px rgba(205,92,92,0.1);
            transition: font-size 0.8s ease;
        }

        /* 装饰元素 */
        .decor {
            position: absolute;
            opacity: 0.6;
            pointer-events: none;
            z-index: 50;
        }

        /* 页面加载动画 */
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        body {
            animation: fadeIn 1s ease;
        }
    </style>
</head>
<body>
    <!-- 开始按钮 -->
    <button id="startBtn">开启心语</button>

    <script>
        // 祝福语列表
        const tips = [
            "保持微笑呀", "每天都要元气满满", "好好爱自己", "别熬夜",
            "今天过得开心嘛", "期待下一次见面", "顺顺利利", "早点休息",
            "梦想成真", "我想你了", "所有烦恼都消失", "天冷了，多穿衣服",
            "对自己好一点~", "保持好心情", "记得吃水果", "要好好生活哦","金榜题名","多喝水哦"
        ];
        
        // 背景颜色列表（更柔和的色调）
        const bgColors = [
            "#d5f5e3", "#d6eaf8", "#fce4ec", "#fef5d4",
            "#e0f7fa", "#f8c4e4", "#ffdab9", "#fff3cd",
            "#ffe4e1", "#f0fff4", "#fff0f3", "#ffead1"
        ];
        
        // 存储所有弹幕元素
        const allWindows = [];
        const totalWindows = 90; // 精简数量，提升性能
        
        // 创建随机装饰元素（增强背景层次感）
        function createDecorElements() {
            const count = 15;
            for (let i = 0; i < count; i++) {
                const decor = document.createElement('div');
                decor.className = 'decor';
                decor.textContent = i % 2 === 0 ? '❀' : '✦';
                decor.style.fontSize = `${Math.random() * 15 + 10}px`;
                decor.style.color = i % 3 === 0 ? '#FF69B4' : '#98D8C8';
                decor.style.left = `${Math.random() * 100}vw`;
                decor.style.top = `${Math.random() * 100}vh`;
                decor.style.animation = `float ${Math.random() * 20 + 30}s linear infinite`;
                document.body.appendChild(decor);
            }
        }

        // 添加漂浮动画
        const style = document.createElement('style');
        style.textContent = `
            @keyframes float {
                0% { transform: translateY(0) rotate(0deg); }
                50% { transform: translateY(-20px) rotate(5deg); }
                100% { transform: translateY(0) rotate(0deg); }
            }
        `;
        document.head.appendChild(style);
        
        // 计算屏幕中心
        function getCenterPosition() {
            return {
                x: window.innerWidth / 2,
                y: window.innerHeight / 2
            };
        }
        
        // 爱心大小比例（精致小巧）
        const scale = Math.min(window.innerWidth, window.innerHeight) / 42;
        
        // 计算爱心曲线上的坐标
        function getHeartCoordinates(angle) {
            const center = getCenterPosition();
            const t = angle * Math.PI / 180;
            const x = 16 * Math.pow(Math.sin(t), 3);
            const y = 13 * Math.cos(t) - 5 * Math.cos(2*t) - 2 * Math.cos(3*t) - Math.cos(4*t);
            return {
                x: center.x + x * scale,
                y: center.y - y * scale
            };
        }
        
        // 创建弹幕窗口（带出现动画）
        function createTipWindow(angle) {
            const { x, y } = getHeartCoordinates(angle);
            const width = Math.floor(Math.random() * 30) + 75;
            const height = Math.floor(Math.random() * 20) + 55;
            
            const div = document.createElement('div');
            div.className = 'tip-window';
            div.style.width = `${width}px`;
            div.style.height = `${height}px`;
            div.style.left = `${x - width/2}px`;
            div.style.top = `${y - height/2}px`;
            div.style.backgroundColor = bgColors[Math.floor(Math.random() * bgColors.length)];
            div.textContent = tips[Math.floor(Math.random() * tips.length)];
            
            document.body.appendChild(div);
            allWindows.push(div);
            
            // 延迟添加出现动画，营造逐个弹出的效果
            setTimeout(() => {
                div.classList.add('show');
            }, 50);
        }
        
        // 显示"我好想你"弹窗
        function showMissYouWindow() {
            // 背景色变化，增强情感氛围
            document.body.style.background = "linear-gradient(135deg, #fff0f3 0%, #ffe4e1 100%)";
            
            const center = getCenterPosition();
            const width = 500;
            const height = 250;
            
            const div = document.createElement('div');
            div.className = 'miss-window';
            div.style.width = `${width}px`;
            div.style.height = `${height}px`;
            div.style.left = `${center.x - width/2}px`;
            div.style.top = `${center.y - height/2}px`;
            
            const text = document.createElement('div');
            text.className = 'miss-text';
            text.textContent = '我好想你';
            div.appendChild(text);
            
            document.body.appendChild(div);
            
            // 渐入动画
            setTimeout(() => {
                div.style.opacity = '0.97';
                div.style.transform = 'scale(1)';
                text.style.fontSize = '45px';
            }, 100);
            
            // 4秒后淡出
            setTimeout(() => {
                div.style.opacity = '0';
                div.style.transform = 'scale(0.9)';
                setTimeout(() => div.remove(), 800);
                
                // 动画结束后恢复背景
                setTimeout(() => {
                    document.body.style.background = "linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%)";
                }, 500);
            }, 4000);
            
            // 点击关闭
            div.addEventListener('click', () => {
                div.style.opacity = '0';
                div.style.transform = 'scale(0.9)';
                setTimeout(() => div.remove(), 800);
            });
        }
        
        // 关闭所有弹幕窗口（可靠的淡出逻辑）
        function closeAllWindows() {
            // 先让所有弹幕停止动画
            allWindows.forEach(win => {
                win.style.transition = 'all 0.6s ease-out';
            });
            
            // 使用Promise确保所有窗口都能被处理
            const fadePromises = allWindows.map(win => {
                return new Promise(resolve => {
                    let opacity = 1;
                    const fadeInterval = setInterval(() => {
                        if (opacity > 0) {
                            opacity -= 0.03;
                            win.style.opacity = opacity;
                            win.style.transform = `scale(${0.8 + opacity * 0.2})`;
                        } else {
                            clearInterval(fadeInterval);
                            if (win.parentNode) win.parentNode.removeChild(win);
                            resolve();
                        }
                    }, 20);
                });
            });
            
            // 所有窗口都消失后再显示最终弹窗
            Promise.all(fadePromises).then(() => {
                setTimeout(showMissYouWindow, 520); // 增加延迟，增强期待感
            });
        }
        
        // 初始化函数
        function init() {
            // 创建背景装饰
            createDecorElements();
            
            let angleStep = 360 / totalWindows;
            let currentAngle = 0;
            
            function createNextWindow() {
                if (allWindows.length < totalWindows) {
                    const randomAngle = currentAngle + (Math.random() * 4 - 2);
                    createTipWindow(randomAngle);
                    currentAngle += angleStep;
                    // 随机化创建间隔，避免机械感
                    const delay = Math.random() * 30 + 50;
                    setTimeout(createNextWindow, delay);
                } else {
                    // 全部创建完成后，5.2秒后开始关闭
                    setTimeout(closeAllWindows, 5200);
                }
            }
            
            createNextWindow();
        }
        
        // 页面加载完成后初始化
        window.onload = () => {
            const startBtn = document.getElementById('startBtn');
            startBtn.addEventListener('click', () => {
                // 按钮淡出动画
                startBtn.style.opacity = '0';
                startBtn.style.transform = 'translate(-50%, -50%) scale(0.8)';
                setTimeout(() => {
                    startBtn.remove();
                    init();
                }, 300);
            });
        };
    </script>
</body>
</html>